package com.vfa.fishing.object;

import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import com.vfa.fishing.GameActivity;
import com.vfa.fishing.common.Constant;

public class Crab extends AbstractObject
{
    public int direction=0;
    public int sideAppear=0;
    public int speed=0;
    public Crab(int x, int y, TiledTextureRegion pTextureRegion, int sideApp)
    {
        super(x, y, pTextureRegion, sideApp);
        // TODO Auto-generated constructor stub
        sideAppear = sideApp;// huong xuat hien cua con ca
        if(sideAppear == Constant.LEFTSIDE)
        {
            direction = Constant.RIGHT;
        }
        else if(sideAppear == Constant.RIGHTSIDE)
        {
            direction = Constant.LEFT;
        }
        this.kindOfObject = Constant.CRAB;
    }

    public void update()
    {
        float  X = 0;
        float  Y = 0;
        X = this.getX();
        Y = this.getY();
        speed = GameActivity.rand.nextInt(10)+1;
        if(direction == Constant.LEFT && !this.checkCollision())
        {
            X -= speed;
            this.setPosition(X, Y);
        }
        else if(direction == Constant.RIGHT&& !this.checkCollision())
        {
            X += speed;
            this.setPosition(X, Y);
        }
    }

    public void Eat()
    {

    }

	@Override
	public void resetDirection() {
		// TODO Auto-generated method stub
		
	}

}
